<template>
  <div id="app">
    <ul>
      <li v-for="(item,index) in arr" :key="index">
        <span>{{item}}</span>
        <button @click="del(index)">删除</button>
      </li>
    </ul>
    <button @click="add">生成</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      arr: [],
    };
  },
  methods: {
    add(){
      let num =Math.floor(Math.random ()*100)
      this.arr.push(num)
      console.log(this.arr)
    },
    del(index){
      console.log(index)
     
        this.arr.splice(index,1)

    }
   
   
  }
}
</script>